home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / Perl_WWW_Utilities / perlMIF_beta2 / mif / mif_fntc.pl < prev    next >
Encoding:
Perl Script  |  1994-05-18  |  8.7 KB  |  279 lines

  1. ##---------------------------------------------------------------------------##
  2. ##  File:
  3. ##      mif_fntc.pl
  4. ##  Author:
  5. ##      Earl Hood       ehood@convex.com
  6. ##  Description:
  7. ##    This file is defines the "mif_fntc" perl package.  It defines
  8. ##    routines to handle the FontCatalog via MIFread_mif() defined in
  9. ##    the "mif" package.
  10. ##---------------------------------------------------------------------------##
  11. ##  Copyright (C) 1994  Earl Hood, ehood@convex.com
  12. ##
  13. ##  This program is free software; you can redistribute it and/or modify
  14. ##  it under the terms of the GNU General Public License as published by
  15. ##  the Free Software Foundation; either version 2 of the License, or
  16. ##  (at your option) any later version.
  17. ## 
  18. ##  This program is distributed in the hope that it will be useful,
  19. ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ##  GNU General Public License for more details.
  22. ##  
  23. ##  You should have received a copy of the GNU General Public License
  24. ##  along with this program; if not, write to the Free Software
  25. ##  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. ##---------------------------------------------------------------------------##
  27.  
  28. require 'mif/mif.pl' || die "Unable to require mif.pl\n";
  29. require 'mif/mif_font.pl' || die "Unable to require mif_font.pl\n";
  30.  
  31. package mif_fntc;
  32.  
  33. ##---------------------------------------------##
  34. ## Add FontCatalog function to %MIFToken array ##
  35. ##---------------------------------------------##
  36. $mif'MIFToken{'FontCatalog'} = 'FontCatalog';
  37.  
  38. ##--------------------------------##
  39. ## FontCatalog associative arrays ##
  40. ##--------------------------------##
  41. %FFamily    = ();    # Name of font family
  42. %FAngle        = ();    # Name of angle
  43. %FWeight    = ();    # Name of weight
  44. %FVar        = ();    # Name of variation
  45. %FPostScriptName = ();    # Name of font sent to PostScript        # Frame 4.x
  46. %FPlatformName    = ();    # Platform-specific font name (Mac/Windows) # Frame 4.x
  47. %FSize        = ();    # Size in points
  48. %FColor        = ();    # Font color
  49. %FUnderline    = ();    # Underline boolean flag            # Frame 3.x
  50. %FDoubleUnderline = ();    # DoubleUnderline boolean flag            # Frame 3.x
  51. %FNumericUnderline = ();# NumericUnderline boolean flag            # Frame 3.x
  52. %FUnderlining    = ();    # Underlining style                # Frame 4.x
  53. %FOverline    = ();    # Overline boolean flag
  54. %FStrike    = ();    # Strikethrough boolean flag
  55. %FSupScript    = ();    # Superscript boolean flag            # Frame 3.x
  56. %FSubScript    = ();    # Subscript boolean flag            # Frame 3.x
  57. %FChangeBar    = ();    # Change bar boolean flag
  58. %FPosition    = ();    # Sub/Superscript                # Frame 4.x
  59. %FOutline    = ();    # Outline boolean flag (Mac)
  60. %FShadow    = ();    # Shadow boolean flag (Mac)
  61. %FPairKern    = ();    # Pair kerning boolean flag
  62. %FCase        = ();    # Capitalization style                # Frame 4.x
  63. %FDX        = ();    # Horizontal manual kern value
  64. %FDY        = ();    # Vertical manual kern value
  65. %FDW        = ();    # Spread value for space between characters
  66. %FPlain        = ();    # Used only by filters
  67. %FBold        = ();    # Used only by filters
  68. %FItalic    = ();    # Used only by filters
  69. %FSeparation    = ();    # Spot color                    # Frame 3.x
  70.  
  71. ##------------------------##
  72. ## Import 'mif' variables ##
  73. ##------------------------##
  74. $MStore        = $mif'MStore;
  75. $MOpen        = $mif'MOpen;
  76. $MClose        = $mif'MClose;
  77. $MLine        = $mif'MLine;
  78. $mso        = $mif'mso;
  79. $msc        = $mif'msc;
  80. $stb        = $mif'stb;
  81. $ste        = $mif'ste;
  82. $como        = $mif'como;
  83.  
  84.                 ##---------------##
  85.                 ## Main Routines ##
  86.                 ##---------------##
  87. ##---------------------------------------------------------------------------
  88. ##    MIFwrite_fntc() outputs the FontCatalog as defined by the
  89. ##    associative arrays.
  90. ##
  91. ##    Usage:
  92. ##        &'MIFwrite_fntc(FILEHANDLE);
  93. ##
  94. sub main'MIFwrite_fntc {
  95.     local($handle, $l) = @_;
  96.     local($i0, $i1, $i2) = (' ' x $l, ' ' x (1+$l), ' ' x (2+$l));
  97.  
  98.     print $handle $i0, $mso, 'FontCatalog', "\n";
  99.     foreach (sort keys %FFamily) {
  100.     &'MIFwrite_font($handle, 1+$l, 'Font',
  101.                 $_,
  102.                 $FFamily{$_},
  103.                 $FAngle{$_},
  104.                 $FWeight{$_},
  105.                 $FVar{$_},
  106.                 $FPostScriptName{$_},
  107.                 $FPlatformName{$_},
  108.                 $FSize{$_},
  109.                 $FColor{$_},
  110.                 $FUnderline{$_},
  111.                 $FDoubleUnderline{$_},
  112.                 $FNumericUnderline{$_},
  113.                 $FUnderlining{$_},
  114.                 $FOverline{$_},
  115.                 $FStrike{$_},
  116.                 $FSupScript{$_},
  117.                 $FSubScript{$_},
  118.                 $FChangeBar{$_},
  119.                 $FPosition{$_},
  120.                 $FOutline{$_},
  121.                 $FShadow{$_},
  122.                 $FPairKern{$_},
  123.                 $FCase{$_},
  124.                 $FDX{$_},
  125.                 $FDY{$_},
  126.                 $FDW{$_},
  127.                 $FPlain{$_},
  128.                 $FBold{$_},
  129.                 $FItalic{$_},
  130.             $FSeparation{$_});
  131.     }
  132.     print $handle $i0, $msc, " $como end of FontCatalog\n";
  133. }
  134. ##---------------------------------------------------------------------------##
  135. ##    MIFget_ftag_data() is a convienence routine that returns the
  136. ##    data associated with the font tag $font.  The data returned
  137. ##    is specific to MIF version 4.x, except it will also return the
  138. ##    FSeparation value.
  139. ##
  140. ##    Usage:
  141. ##        ($family, $angle, $weight, $var, $size, $undlining, $overline,
  142. ##         $strike, $chngbar, $position, $outline, $shadow, $pairkern,
  143. ##         $case, $dx, $dy, $dw, $color, $separation)
  144. ##        =
  145. ##        &'MIFget_ftag_data($font);
  146. ##
  147. sub main'MIFget_ftag_data {
  148.     local($font) = @_;
  149.     ($FFamily{$font},
  150.      $FAngle{$font},
  151.      $FWeight{$font},
  152.      $FVar{$font},
  153.      $FSize{$font},
  154.      $FUnderlining{$font},
  155.      $FOverline{$font},
  156.      $FStrike{$font},
  157.      $FChangeBar{$font},
  158.      $FPosition{$font},
  159.      $FOutline{$font},
  160.      $FShadow{$font},
  161.      $FPairKern{$font},
  162.      $FCase{$font},
  163.      $FDX{$font},
  164.      $FDY{$font},
  165.      $FDW{$font},
  166.      $FColor{$font},
  167.      $FSeparation{$font});
  168. }
  169. ##---------------------------------------------------------------------------##
  170. ##      MIFget_ftags() returns a sorted array of all font tag names
  171. ##      defined in the font catalog.
  172. ##
  173. ##      Usage:
  174. ##          @ftags = &'MIFget_ftags();
  175. ##
  176. sub main'MIFget_ftags {
  177.      return sort keys %FFamily;
  178. }
  179. ##---------------------------------------------------------------------------##
  180. ##    MIFreset_fntc() resets all the associative arrays defining the
  181. ##    font catalog.
  182. ##
  183. sub main'MIFreset_fntc {
  184.     undef %FFamily;
  185.     undef %FAngle;
  186.     undef %FWeight;
  187.     undef %FVar;
  188.     undef %FPostScriptName;
  189.     undef %FPlatformName;
  190.     undef %FSize;
  191.     undef %FColor;
  192.     undef %FUnderline;
  193.     undef %FDoubleUnderline;
  194.     undef %FNumericUnderline;
  195.     undef %FUnderlining;
  196.     undef %FOverline;
  197.     undef %FStrike;
  198.     undef %FSupScript;
  199.     undef %FSubScript;
  200.     undef %FChangeBar;
  201.     undef %FPosition;
  202.     undef %FOutline;
  203.     undef %FShadow;
  204.     undef %FPairKern;
  205.     undef %FCase;
  206.     undef %FDX;
  207.     undef %FDY;
  208.     undef %FDW;
  209.     undef %FPlain;
  210.     undef %FBold;
  211.     undef %FItalic;
  212.     undef %FSeparation;
  213. }
  214. ##---------------------------------------------------------------------------##
  215.                 ##--------------##
  216.                 ## Mif Routines ##
  217.                 ##--------------##
  218. ##---------------------------------------------------------------------------##
  219. ##    The routines definded below are all registered in the %MIFToken         ##
  220. ##    array for use in the MIFread_mif() routine.  There purpose is to     ##
  221. ##    store the information contained in the font catalog.             ##
  222. ##---------------------------------------------------------------------------##
  223.  
  224. ##---------------------------------------------------------------------------
  225. ##    FontCatalog() is the token routine for 'FontCatalog'.
  226. ##    It sets/restores token routines depending upon mode.
  227. ##
  228. sub mif'FontCatalog {
  229.     local($token, $mode, *data) = @_;
  230.     if ($mode == $MOpen) {
  231.     ($_fast, $_noidata) = ($mif'fast, $mif'no_import_data);
  232.     ($mif'fast, $mif'no_import_data) = (1, 1);
  233.     $_fntc_orgfunc = &'MIFget_font_func();
  234.     &'MIFset_font_func("mif_fntc'font_close");
  235.     } elsif ($mode == $MClose) {
  236.     &'MIFset_font_func($_fntc_orgfunc);
  237.         ($mif'fast, $mif'no_import_data) = ($_fast, $_noidata);
  238.     }
  239. }
  240. ##---------------------------------------------------------------------------
  241. sub font_close {
  242.     local($token, $tag, $tmp);
  243.     $tag = $mif_font'fnt_Tag;
  244.   
  245.     ($token,
  246.      $tmp,
  247.      $FFamily{$tag},
  248.      $FAngle{$tag},
  249.      $FWeight{$tag},
  250.      $FVar{$tag},
  251.      $FPostScriptName{$tag},
  252.      $FPlatformName{$tag},
  253.      $FSize{$tag},
  254.      $FColor{$tag},
  255.      $FUnderline{$tag},
  256.      $FDoubleUnderline{$tag},
  257.      $FNumericUnderline{$tag},
  258.      $FUnderlining{$tag},
  259.      $FOverline{$tag},
  260.      $FStrike{$tag},
  261.      $FSupScript{$tag},
  262.      $FSubScript{$tag},
  263.      $FChangeBar{$tag},
  264.      $FPosition{$tag},
  265.      $FOutline{$tag},
  266.      $FShadow{$tag},
  267.      $FPairKern{$tag},
  268.      $FCase{$tag},
  269.      $FDX{$tag},
  270.      $FDY{$tag},
  271.      $FDW{$tag},
  272.      $FPlain{$tag},
  273.      $FBold{$tag},
  274.      $FItalic{$tag},
  275.      $FSeparation{$tag}) = &'MIFget_last_font_data();
  276. }
  277. ##---------------------------------------------------------------------------
  278. 1;
  279.